package com.qf.android.huihui.bean.show.shoppingbottom;

import com.qf.android.huihui.bean.ShoppingBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 韩爽 on 2017/1/11.
 */

public class CommonBean {

    private HotBusiness hotBusiness;
    private Hot hot;
    private  ShoppingBean shoppingBean;
    private  ShoppingBottomBean shoppingBottomBean;

    public CommonBean(Hot hot, ShoppingBottomBean shoppingBottomBean) {
        this.hot = hot;
        this.shoppingBottomBean = shoppingBottomBean;
    }

    public CommonBean(HotBusiness hotBusiness, Hot hot, ShoppingBean shoppingBean, ShoppingBottomBean shoppingBottomBean) {
        this.hotBusiness = hotBusiness;
        this.hot = hot;
        this.shoppingBean = shoppingBean;
        this.shoppingBottomBean=shoppingBottomBean;
    }
    public List<ShoppingBase> getList(){
     List<ShoppingBase> list=new ArrayList<>();
        list.add(shoppingBean);
        list.add(hotBusiness.getData().getHots());
        list.add(hotBusiness.getData().getDmail());
        list.add(hot);
        list.addAll(getData(list));
        return  list;
    }
    public List<ShoppingBase> getData(List<ShoppingBase> beanList){
       String tips = shoppingBottomBean.getData().getTips();
       List<ShoppingBottomBean.DataBean.ListBeanXX> list = shoppingBottomBean.getData().getList();
        HuiItemClass huiItemClass=null;
       HaitaoItemClass haitaoItemClass=null;
       for (int i = 0; i < list.size(); i++) {
           //获取每一个item
           ShoppingBottomBean.DataBean.ListBeanXX listBeanXX = list.get(i);

           if("HaitaoItem".equals(listBeanXX.getType())){
               //大家都在买
               if(haitaoItemClass==null){
                   haitaoItemClass=new HaitaoItemClass();
               }else {
                   if (haitaoItemClass.getList().size()==6){
                       beanList.add(haitaoItemClass);
                       haitaoItemClass=null;
                   }else
                       haitaoItemClass.getList().add(listBeanXX.getHaitaoItem());
               }
           }else  if("HotSearch".equals(listBeanXX.getType())){
               //热门搜索
                  beanList.add(listBeanXX.getHotSearch());
           }else if("BrandDay".equals(listBeanXX.getType())){
               //品牌日
               beanList.add(listBeanXX.getBrandDay());
           }else if("HuiHuodong".equals(listBeanXX.getType())){
              //活动
               beanList.add(listBeanXX.getHuiHuodong());
           }else if("HuiItem".equals(listBeanXX.getType())){
               //小编推荐
               if(huiItemClass==null){
                   huiItemClass= new HuiItemClass();
               }
                huiItemClass.getList().add(listBeanXX.getHuiItem());
           }else if("TopicGroup".equals(listBeanXX.getType())){
               //热销榜
               beanList.add(listBeanXX.getTopicGroup());
           }else  if("Shaidan".equals(listBeanXX.getType())){
               //晒单
               beanList.add(listBeanXX.getShaiDan());
           }else if("Qingdan".equals(listBeanXX.getType())){
               //清单
               beanList.add(listBeanXX.getQingDan());
           }else if("HuiZixun".equals(listBeanXX.getType())){
               //资讯
               beanList.add(listBeanXX.getHuiZixun());
           }
       }
       if(huiItemClass!=null){
          beanList.add(huiItemClass);
       }
       return beanList;
   }

   public static class HaitaoItemClass implements ShoppingBase{
        List<ShoppingBottomBean.DataBean.ListBeanXX.HaitaoItemBean> list=new ArrayList<>();


        public List<ShoppingBottomBean.DataBean.ListBeanXX.HaitaoItemBean> getList() {
            return list;
        }

        public void setList(List<ShoppingBottomBean.DataBean.ListBeanXX.HaitaoItemBean> list) {
            this.list = list;
        }
    }
   public static class HuiItemClass implements ShoppingBase{
        List<ShoppingBottomBean.DataBean.ListBeanXX.HuiItemBean> list=new ArrayList<>();


        public List<ShoppingBottomBean.DataBean.ListBeanXX.HuiItemBean> getList() {
            return list;
        }

        public void setList(List<ShoppingBottomBean.DataBean.ListBeanXX.HuiItemBean> list) {
            this.list = list;
        }
    }
}
